﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;

public partial class Paypal : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Label3.Text = Request.QueryString["Total"];
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Response.Redirect("peorder");
    }
    protected void Button1_Click1(object sender, EventArgs e)
    {
        Response.Redirect("payment.aspx");
    }
    protected void Button2_Click(object sender, EventArgs e)
    
       
   {
  
         SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["RegConnectionString"].ConnectionString);
    con.Open();
    string insCmd = "Insert into PayDate(Username, ExpiryDate, AccountNumber, CvcCode) values (@UserName,@ExpiryDate,@AccountNumber,@CvcCode)";
    SqlCommand insertUser = new SqlCommand(insCmd, con);
    insertUser.Parameters.AddWithValue("@Username", TextBox1.Text);
    insertUser.Parameters.AddWithValue("@ExpiryDate", TextBox2.Text);
    insertUser.Parameters.AddWithValue("@AccountNumber", TextBox3.Text);
    insertUser.Parameters.AddWithValue("@CvcCode", TextBox4.Text);
    


    try
    {
        insertUser.ExecuteNonQuery();
        con.Close();
        Response.Redirect("CusDeliveryInfo.aspx?Name=" + Server.UrlEncode(TextBox1.Text) + "&Total=" + Label3.Text);

    }

    catch (Exception ex)
    {
        if (ex is SqlException)
        {
            Response.Write("<b>Something Really Bad Happened...Please try Again.</b>");
        }
    }
    finally
    {
        //Any Special Action you want to Add.........
    }

}

}